﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Ex7.ExtractURLs
{
    class ExtractURL
    {
        public static void ExtractURLs(string text)
        {
            string expression = @"(http://|www\.)(\w+\.)+(\w+){2,4}";
            Regex regex = new Regex(expression, RegexOptions.IgnoreCase);
            MatchCollection match = regex.Matches(text);

            if (match.Count > 0)
            {
                Console.Write("URLs: ");
                foreach (var word in match)
                {
                    Console.Write("\"{0}\", ", word);
                }
            }
            else
            {
                Console.WriteLine("No URLs were found!");
            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            string text = "abalas ash www.abv.bg tewqssdf eerrr http://google.com asdt www.dox.abv.bg";
            ExtractURLs(text);
        }
    }
}
